﻿namespace UnityEditor
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using UnityEditorInternal;
    using UnityEngine;

    public class SceneView : SearchableEditorWindow
    {
        [CompilerGenerated]
        private static Dictionary<string, int> <>f__switch$map16;
        [SerializeField]
        private SceneViewGrid grid;
        private const float kOneOverSqrt2 = 0.7071068f;
        private const float kOrthoThresholdAngle = 3f;
        private const float kPerspectiveFov = 90f;
        private static PrefColor kSceneViewBackground = new PrefColor("Scene/Background", 0.278431f, 0.278431f, 0.278431f, 0f);
        internal static Color kSceneViewDownLight = new Color(0.047f, 0.043f, 0.035f, 1f);
        internal static Color kSceneViewFrontLight = new Color(0.769f, 0.769f, 0.769f, 1f);
        internal static Color kSceneViewMidLight = new Color(0.114f, 0.125f, 0.133f, 1f);
        internal static Color kSceneViewUpLight = new Color(0.212f, 0.227f, 0.259f, 1f);
        private static PrefColor kSceneViewWire = new PrefColor("Scene/Wireframe", 0f, 0f, 0f, 0.5f);
        private static PrefColor kSceneViewWireActive = new PrefColor("Scene/Wireframe Active", 0.4901961f, 0.6901961f, 0.9803922f, 0.372549f);
        private static PrefColor kSceneViewWireOverlay = new PrefColor("Scene/Wireframe Overlay", 0f, 0f, 0f, 0.25f);
        private static PrefColor kSceneViewWireSelected = new PrefColor("Scene/Wireframe Selected", 0.3686275f, 0.4666667f, 0.6078432f, 0.25f);
        public const float kToolbarHeight = 17f;
        [NonSerialized]
        internal AnimValueManager m_AnimValueManager;
        [NonSerialized]
        public bool m_AudioPlay;
        [NonSerialized]
        private Camera m_Camera;
        private EditorCache m_DragEditorCache;
        [NonSerialized]
        private Light[] m_Light = new Light[3];
        private int m_MainViewControlID;
        [SerializeField]
        internal AnimBool m_Ortho = new AnimBool();
        public int m_OverlayMode;
        [SerializeField]
        private AnimVector3 m_Position = new AnimVector3();
        private RectSelection m_RectSelection;
        public DrawCameraMode m_RenderMode;
        private bool m_RequestedSceneViewFiltering;
        [SerializeField]
        internal AnimQuaternion m_Rotation = new AnimQuaternion(Quaternion.LookRotation(new Vector3(-1f, -0.7f, -1f)));
        public bool m_SceneFx;
        public bool m_SceneLighting;
        private SceneViewOverlay m_SceneViewOverlay;
        private RenderTexture m_SearchFilterTexture;
        internal bool m_ShowSceneViewWindows;
        [SerializeField]
        private AnimFloat m_Size = new AnimFloat(10f);
        private double m_StartSearchFilterTime = -1.0;
        [NonSerialized]
        private ActiveEditorTracker m_Tracker;
        public static OnSceneFunc onSceneGUIDelegate;
        private static Material s_AlphaOverlayMaterial;
        private static GUIContent s_AudioPlay = EditorGUIUtility.IconContent("SceneviewAudio");
        private static SceneView s_AudioSceneView = null;
        private static Shader s_AuraShader;
        private static SceneView s_CurrentDrawingSceneView;
        private static Tool s_CurrentTool;
        private bool s_DraggingCursorIsCashed;
        private static GUIContent s_Fx = EditorGUIUtility.IconContent("SceneviewFx");
        private static GUIContent s_GizmosContent = new GUIContent("Gizmos");
        private static Shader s_GrayScaleShader;
        private static SceneView s_LastActiveSceneView;
        private static MouseCursor s_LastCursor = MouseCursor.Arrow;
        private static GUIContent s_Lighting = EditorGUIUtility.IconContent("SceneviewLighting");
        private static Texture2D s_MipColorsTexture;
        private static List<CursorRect> s_MouseRects = new List<CursorRect>();
        private static string[] s_OverlayModes = new string[] { "RGB", "Alpha", "Overdraw", "Mipmaps" };
        private static string[] s_RenderModes = new string[] { "Textured", "Wireframe", "Textured Wire", "Render Paths", "Lightmap Resolution" };
        private static ArrayList s_SceneViews = new ArrayList();
        private static Shader s_ShowLightmapsShader;
        private static Shader s_ShowMipsShader;
        private static Shader s_ShowOverdrawShader;
        [NonSerialized]
        private bool slomo;
        [SerializeField]
        internal SceneViewRotation svRot;

        public SceneView()
        {
            base.m_HierarchyType = HierarchyType.GameObjects;
            base.depthBufferBits = 0x20;
            base.antiAlias = -1;
        }

        internal static void AddCursorRect(Rect rect, MouseCursor cursor)
        {
            if (Event.current.type == EventType.Repaint)
            {
                s_MouseRects.Add(new CursorRect(rect, cursor));
            }
        }

        public void AlignViewToObject(Transform t)
        {
            this.FixNegativeSize();
            this.size = 10f;
            this.LookAt(t.position + ((Vector3) (t.forward * this.CalcCameraDist())), t.rotation);
        }

        public void AlignWithView()
        {
            float num;
            Vector3 vector3;
            this.FixNegativeSize();
            Vector3 position = this.camera.transform.position;
            Vector3 vector2 = position - Tools.handlePosition;
            (Quaternion.Inverse(Selection.activeTransform.rotation) * this.camera.transform.rotation).ToAngleAxis(out num, out vector3);
            vector3 = Selection.activeTransform.TransformDirection(vector3);
            Undo.RegisterUndo(Selection.activeTransform, Selection.transforms, "Align with view");
            foreach (Transform transform in Selection.transforms)
            {
                transform.position += vector2;
                transform.RotateAround(position, vector3, num);
            }
        }

        private void Awake()
        {
            this.m_SceneLighting = InternalEditorUtility.CalculateShouldEnableLights();
        }

        private float CalcCameraDist()
        {
            float num = this.m_Ortho.Fade(90f, 0f);
            if (num > 3f)
            {
                this.m_Camera.orthographic = false;
                return (this.size / Mathf.Tan((num * 0.5f) * 0.01745329f));
            }
            return 0f;
        }

        private void CallEditorDragFunctions()
        {
            if (DragAndDrop.objectReferences.Length != 0)
            {
                if (this.m_DragEditorCache == null)
                {
                    this.m_DragEditorCache = new EditorCache(EditorFeatures.OnSceneDrag);
                }
                foreach (UnityEngine.Object obj2 in DragAndDrop.objectReferences)
                {
                    if (obj2 != null)
                    {
                        EditorWrapper wrapper = this.m_DragEditorCache[obj2];
                        if (wrapper != null)
                        {
                            wrapper.OnSceneDrag();
                        }
                        if (Event.current.type == EventType.Used)
                        {
                            return;
                        }
                    }
                }
            }
        }

        private void CallOnPreSceneGUI()
        {
            foreach (Editor editor in this.GetActiveEditors())
            {
                Handles.matrix = Matrix4x4.identity;
                Component target = editor.target as Component;
                if ((target == null) || target.gameObject.activeInHierarchy)
                {
                    MethodInfo method = editor.GetType().GetMethod("OnPreSceneGUI", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                    if (method != null)
                    {
                        for (int i = 0; i < editor.targets.Length; i++)
                        {
                            editor.referenceTargetIndex = i;
                            Editor.m_AllowMultiObjectAccess = !editor.canEditMultipleObjects;
                            method.Invoke(editor, null);
                            Editor.m_AllowMultiObjectAccess = true;
                        }
                    }
                }
            }
            Handles.matrix = Matrix4x4.identity;
        }

        private void CallOnSceneGUI()
        {
            s_CurrentDrawingSceneView = this;
            foreach (Editor editor in this.GetActiveEditors())
            {
                Handles.matrix = Matrix4x4.identity;
                if (EditorGUIUtility.IsGizmosAllowedForObject(editor.target))
                {
                    MethodInfo method = editor.GetType().GetMethod("OnSceneGUI", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                    if (method != null)
                    {
                        for (int i = 0; i < editor.targets.Length; i++)
                        {
                            editor.referenceTargetIndex = i;
                            EditorGUI.BeginChangeCheck();
                            Editor.m_AllowMultiObjectAccess = !editor.canEditMultipleObjects;
                            method.Invoke(editor, null);
                            Editor.m_AllowMultiObjectAccess = true;
                            if (EditorGUI.EndChangeCheck())
                            {
                                editor.serializedObject.SetIsDifferentCacheDirty();
                            }
                        }
                    }
                }
            }
            Handles.matrix = Matrix4x4.identity;
        }

        private void CallOnSceneGUIAfterGizmos()
        {
            if (onSceneGUIDelegate != null)
            {
                onSceneGUIDelegate(this);
            }
            Handles.matrix = Matrix4x4.identity;
        }

        private void CleanupEditorDragFunctions()
        {
            if (this.m_DragEditorCache != null)
            {
                this.m_DragEditorCache.Dispose();
            }
            this.m_DragEditorCache = null;
        }

        private void CommandsGUI()
        {
            bool flag = Event.current.type == EventType.ExecuteCommand;
            string commandName = Event.current.commandName;
            if (commandName != null)
            {
                int num;
                if (<>f__switch$map16 == null)
                {
                    Dictionary<string, int> dictionary = new Dictionary<string, int>(8);
                    dictionary.Add("Find", 0);
                    dictionary.Add("FrameSelected", 1);
                    dictionary.Add("SoftDelete", 2);
                    dictionary.Add("Delete", 2);
                    dictionary.Add("Duplicate", 3);
                    dictionary.Add("Copy", 4);
                    dictionary.Add("Paste", 5);
                    dictionary.Add("SelectAll", 6);
                    <>f__switch$map16 = dictionary;
                }
                if (<>f__switch$map16.TryGetValue(commandName, out num))
                {
                    switch (num)
                    {
                        case 0:
                            if (flag)
                            {
                                base.FocusSearchField();
                            }
                            Event.current.Use();
                            break;

                        case 1:
                            if (flag)
                            {
                                this.FrameSelected();
                            }
                            Event.current.Use();
                            break;

                        case 2:
                            if (flag)
                            {
                                Unsupported.DeleteGameObjectSelection();
                            }
                            Event.current.Use();
                            break;

                        case 3:
                            if (flag)
                            {
                                Unsupported.DuplicateGameObjectsUsingPasteboard();
                            }
                            Event.current.Use();
                            break;

                        case 4:
                            if (flag)
                            {
                                Unsupported.CopyGameObjectsToPasteboard();
                            }
                            Event.current.Use();
                            break;

                        case 5:
                            if (flag)
                            {
                                Unsupported.PasteGameObjectsFromPasteboard();
                            }
                            Event.current.Use();
                            break;

                        case 6:
                            if (flag)
                            {
                                Selection.objects = UnityEngine.Object.FindObjectsOfType(typeof(GameObject));
                            }
                            Event.current.Use();
                            break;
                    }
                }
            }
        }

        private static void CreateMipColorsTexture()
        {
            if (s_MipColorsTexture == null)
            {
                s_MipColorsTexture = new Texture2D(0x20, 0x20, TextureFormat.ARGB32, true);
                s_MipColorsTexture.hideFlags = HideFlags.HideAndDontSave;
                Color[] colorArray = new Color[] { new Color(0f, 0f, 1f, 0.8f), new Color(0f, 0.5f, 1f, 0.4f), new Color(1f, 1f, 1f, 0f), new Color(1f, 0.7f, 0f, 0.2f), new Color(1f, 0.3f, 0f, 0.6f), new Color(1f, 0f, 0f, 0.8f) };
                int num = Mathf.Min(6, s_MipColorsTexture.mipmapCount);
                for (int i = 0; i < num; i++)
                {
                    int num3 = Mathf.Max(s_MipColorsTexture.width >> i, 1);
                    int num4 = Mathf.Max(s_MipColorsTexture.height >> i, 1);
                    Color[] colors = new Color[num3 * num4];
                    for (int j = 0; j < colors.Length; j++)
                    {
                        colors[j] = colorArray[i];
                    }
                    s_MipColorsTexture.SetPixels(colors, i);
                }
                s_MipColorsTexture.filterMode = UnityEngine.FilterMode.Trilinear;
                s_MipColorsTexture.Apply(false);
                Shader.SetGlobalTexture("__SceneViewMipcolorsTexture", s_MipColorsTexture);
            }
        }

        private void DefaultHandles()
        {
            if (GUIUtility.hotControl == 0)
            {
                s_CurrentTool = !Tools.viewToolActive ? Tools.current : Tool.View;
            }
            Tool tool2 = (Event.current.type != EventType.Repaint) ? s_CurrentTool : Tools.current;
            switch ((tool2 + 1))
            {
                case Tool.Rotate:
                    MoveTool.OnGUI();
                    break;

                case Tool.Scale:
                    RotateTool.OnGUI();
                    break;

                case ((Tool) 4):
                    ScaleTool.OnGUI();
                    break;
            }
        }

        private void DoStatusBarGUI()
        {
            GUILayout.BeginHorizontal("toolbar", new GUILayoutOption[0]);
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(120f) };
            this.m_RenderMode = (DrawCameraMode) EditorGUILayout.Popup((int) this.m_RenderMode, s_RenderModes, "ToolbarPopup", options);
            EditorGUILayout.Space();
            bool enabled = GUI.enabled;
            GUI.enabled = string.IsNullOrEmpty(base.m_SearchFilter);
            GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(70f) };
            this.m_OverlayMode = EditorGUILayout.Popup(this.m_OverlayMode, s_OverlayModes, "ToolbarPopup", optionArray2);
            GUI.enabled = enabled;
            EditorGUILayout.Space();
            this.m_SceneLighting = GUILayout.Toggle(this.m_SceneLighting, s_Lighting, "toolbarbutton", new GUILayoutOption[0]);
            this.m_SceneFx = GUILayout.Toggle(this.m_SceneFx, s_Fx, "toolbarbutton", new GUILayoutOption[0]);
            GUI.enabled = !Application.isPlaying;
            GUI.changed = false;
            this.m_AudioPlay = GUILayout.Toggle(this.m_AudioPlay, s_AudioPlay, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            if (GUI.changed)
            {
                this.ToggleAudio();
            }
            GUI.enabled = true;
            GUILayout.Space(6f);
            GUILayout.FlexibleSpace();
            if (((this.m_MainViewControlID != GUIUtility.keyboardControl) && (Event.current.type == EventType.KeyDown)) && !string.IsNullOrEmpty(base.m_SearchFilter))
            {
                switch (Event.current.keyCode)
                {
                    case KeyCode.UpArrow:
                    case KeyCode.DownArrow:
                        if (Event.current.keyCode == KeyCode.UpArrow)
                        {
                            base.SelectPreviousSearchResult();
                        }
                        else
                        {
                            base.SelectNextSearchResult();
                        }
                        this.FrameSelected();
                        Event.current.Use();
                        GUIUtility.ExitGUI();
                        return;
                }
            }
            if (EditorGUI.ButtonMouseDown(GUILayoutUtility.GetRect(s_GizmosContent, EditorStyles.toolbarDropDown), s_GizmosContent, FocusType.Passive, EditorStyles.toolbarDropDown) && AnnotationWindow.ShowAtPosition(GUILayoutUtility.topLevel.GetLast()))
            {
                GUIUtility.ExitGUI();
            }
            GUILayout.Space(6f);
            base.SearchFieldGUI();
            this.m_AnimValueManager.speed = !this.slomo ? 2f : 0.2f;
            GUILayout.EndHorizontal();
        }

        private void DrawAlphaOverlay()
        {
            if (this.m_OverlayMode == 1)
            {
                if (s_AlphaOverlayMaterial == null)
                {
                    s_AlphaOverlayMaterial = EditorGUIUtility.LoadRequired("SceneView/SceneViewAlphaMaterial.mat") as Material;
                }
                Handles.BeginGUI();
                if (Event.current.type == EventType.Repaint)
                {
                    Graphics.DrawTexture(new Rect(0f, 0f, base.position.width, base.position.height), EditorGUIUtility.whiteTexture, s_AlphaOverlayMaterial);
                }
                Handles.EndGUI();
            }
        }

        public void FixNegativeSize()
        {
            float num = 90f;
            if (this.size < 0f)
            {
                float z = this.size / Mathf.Tan((num * 0.5f) * 0.01745329f);
                Vector3 vector = (Vector3) (this.m_Position + (this.rotation * new Vector3(0f, 0f, -z)));
                this.size = -this.size;
                z = this.size / Mathf.Tan((num * 0.5f) * 0.01745329f);
                this.m_Position.value = vector + (this.rotation * new Vector3(0f, 0f, z));
            }
        }

        public static bool FrameLastActiveSceneView()
        {
            if (lastActiveSceneView == null)
            {
                return false;
            }
            return lastActiveSceneView.SendEvent(EditorGUIUtility.CommandEvent("FrameSelected"));
        }

        public bool FrameSelected()
        {
            this.FixNegativeSize();
            Bounds bounds = InternalEditorUtility.CalculateSelectionBounds(false);
            foreach (Editor editor in this.GetActiveEditors())
            {
                MethodInfo method = editor.GetType().GetMethod("HasFrameBounds", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                if (method != null)
                {
                    object obj2 = method.Invoke(editor, null);
                    if (((obj2 != null) && (obj2 is bool)) && ((bool) obj2))
                    {
                        MethodInfo info2 = editor.GetType().GetMethod("OnGetFrameBounds", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                        if (info2 != null)
                        {
                            object obj3 = info2.Invoke(editor, null);
                            if ((obj3 != null) && (obj3 is Bounds))
                            {
                                bounds = (Bounds) obj3;
                            }
                        }
                    }
                }
            }
            float num2 = bounds.extents.magnitude * 1.5f;
            switch (num2)
            {
                case float.PositiveInfinity:
                    return false;

                case 0f:
                    num2 = 10f;
                    break;
            }
            this.LookAt(bounds.center, this.m_Rotation.target, num2 * 2.2f);
            return true;
        }

        private Editor[] GetActiveEditors()
        {
            if (this.m_Tracker == null)
            {
                this.m_Tracker = ActiveEditorTracker.sharedTracker;
            }
            return this.m_Tracker.activeEditors;
        }

        public static Camera[] GetAllSceneCameras()
        {
            ArrayList list = new ArrayList();
            for (int i = 0; i < s_SceneViews.Count; i++)
            {
                Camera camera = ((SceneView) s_SceneViews[i]).m_Camera;
                if (camera != null)
                {
                    list.Add(camera);
                }
            }
            return (Camera[]) list.ToArray(typeof(Camera));
        }

        internal static RenderingPath GetSceneViewRenderingPath()
        {
            Camera mainCamera = Camera.mainCamera;
            if (mainCamera != null)
            {
                return mainCamera.renderingPath;
            }
            Camera[] allCameras = Camera.allCameras;
            if ((allCameras != null) && (allCameras.Length == 1))
            {
                return allCameras[0].renderingPath;
            }
            return RenderingPath.UsePlayerSettings;
        }

        internal float GetVerticalFOV(float aspectNeutralFOV)
        {
            float f = (Mathf.Tan((aspectNeutralFOV * 0.5f) * 0.01745329f) * 0.7071068f) / Mathf.Sqrt(this.m_Camera.aspect);
            return ((Mathf.Atan(f) * 2f) * 57.29578f);
        }

        internal float GetVerticalOrthoSize()
        {
            return ((this.size * 0.7071068f) / Mathf.Sqrt(this.m_Camera.aspect));
        }

        private void HandleDragging()
        {
            Event current = Event.current;
            EventType type = current.type;
            switch (type)
            {
                case EventType.Repaint:
                    this.CallEditorDragFunctions();
                    return;

                case EventType.DragUpdated:
                case EventType.DragPerform:
                    this.CallEditorDragFunctions();
                    if (current.type != EventType.Used)
                    {
                        DragAndDrop.visualMode = InternalEditorUtility.SceneViewDrag(HandleUtility.PickGameObject(Event.current.mousePosition, true), this.pivot, Event.current.mousePosition, current.type == EventType.DragPerform);
                        if ((current.type == EventType.DragPerform) && (DragAndDrop.visualMode != DragAndDropVisualMode.None))
                        {
                            DragAndDrop.AcceptDrag();
                            current.Use();
                            GUIUtility.ExitGUI();
                        }
                        current.Use();
                        return;
                    }
                    return;
            }
            if (type == EventType.DragExited)
            {
                this.CallEditorDragFunctions();
                this.CleanupEditorDragFunctions();
            }
        }

        private void HandleSelectionAndOnSceneGUI()
        {
            this.m_RectSelection.OnGUI();
            this.CallOnSceneGUI();
        }

        public void LookAt(Vector3 position)
        {
            this.FixNegativeSize();
            this.m_Position.target = position;
        }

        public void LookAt(Vector3 position, Quaternion rotation)
        {
            this.FixNegativeSize();
            this.m_Position.target = position;
            this.m_Rotation.target = rotation;
            this.svRot.UpdateGizmoLabel(this, (Vector3) (rotation * Vector3.forward), this.m_Ortho.target);
        }

        public void LookAt(Vector3 position, Quaternion rotation, float size)
        {
            this.FixNegativeSize();
            this.m_Position.target = position;
            this.m_Rotation.target = rotation;
            this.m_Size.target = Mathf.Abs(size);
            this.svRot.UpdateGizmoLabel(this, (Vector3) (rotation * Vector3.forward), this.m_Ortho.target);
        }

        public void LookAt(Vector3 position, Quaternion rotation, float size, bool orthographic)
        {
            this.FixNegativeSize();
            this.m_Position.target = position;
            this.m_Rotation.target = rotation;
            this.m_Size.target = Mathf.Abs(size);
            this.m_Ortho.target = orthographic;
            this.svRot.UpdateGizmoLabel(this, (Vector3) (rotation * Vector3.forward), this.m_Ortho.target);
        }

        public void LookAtDirect(Vector3 position, Quaternion rotation)
        {
            this.FixNegativeSize();
            this.m_Position.value = position;
            this.m_Rotation.value = rotation;
            this.svRot.UpdateGizmoLabel(this, (Vector3) (rotation * Vector3.forward), this.m_Ortho.target);
        }

        public void LookAtDirect(Vector3 position, Quaternion rotation, float size)
        {
            this.FixNegativeSize();
            this.m_Position.value = position;
            this.m_Rotation.value = rotation;
            this.m_Size.value = Mathf.Abs(size);
            this.svRot.UpdateGizmoLabel(this, (Vector3) (rotation * Vector3.forward), this.m_Ortho.target);
        }

        [UnityEditor.MenuItem("GameObject/Align View to Selected")]
        private static void MenuAlignViewToSelected()
        {
            if (ValidateAlignViewToSelected())
            {
                s_LastActiveSceneView.AlignViewToObject(Selection.activeTransform);
            }
        }

        [UnityEditor.MenuItem("GameObject/Align With View %#f")]
        private static void MenuAlignWithView()
        {
            if (ValidateAlignWithView())
            {
                s_LastActiveSceneView.AlignWithView();
            }
        }

        [UnityEditor.MenuItem("GameObject/Move To View %&f")]
        private static void MenuMoveToView()
        {
            if (ValidateMoveToView())
            {
                s_LastActiveSceneView.MoveToView();
            }
        }

        public void MoveToView()
        {
            this.FixNegativeSize();
            Vector3 vector = this.pivot - Tools.handlePosition;
            Undo.RegisterUndo(Selection.activeTransform, Selection.transforms, "Move to view");
            foreach (Transform transform in Selection.transforms)
            {
                transform.position += vector;
            }
        }

        public void MoveToView(Transform target)
        {
            target.position = this.pivot;
        }

        public void OnDestroy()
        {
            if (this.m_AudioPlay)
            {
                this.m_AudioPlay = false;
                this.ToggleAudio();
            }
        }

        private void OnDidOpenScene()
        {
            IEnumerator enumerator = s_SceneViews.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    SceneView current = (SceneView) enumerator.Current;
                    current.m_SceneLighting = InternalEditorUtility.CalculateShouldEnableLights();
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable == null)
                {
                }
                disposable.Dispose();
            }
        }

        public override void OnDisable()
        {
            EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction) Delegate.Remove(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(SceneView.RepaintAll));
            if (this.m_Camera != null)
            {
                UnityEngine.Object.DestroyImmediate(this.m_Camera.gameObject, true);
            }
            if (this.m_Light[0] != null)
            {
                UnityEngine.Object.DestroyImmediate(this.m_Light[0].gameObject, true);
            }
            if (this.m_Light[1] != null)
            {
                UnityEngine.Object.DestroyImmediate(this.m_Light[1].gameObject, true);
            }
            if (this.m_Light[2] != null)
            {
                UnityEngine.Object.DestroyImmediate(this.m_Light[2].gameObject, true);
            }
            if (s_MipColorsTexture != null)
            {
                UnityEngine.Object.DestroyImmediate(s_MipColorsTexture, true);
            }
            s_SceneViews.Remove(this);
            if (s_LastActiveSceneView == this)
            {
                if (s_SceneViews.Count > 0)
                {
                    s_LastActiveSceneView = s_SceneViews[0] as SceneView;
                }
                else
                {
                    s_LastActiveSceneView = null;
                }
            }
            this.CleanupEditorDragFunctions();
            base.OnDisable();
        }

        public override void OnEnable()
        {
            this.m_RectSelection = new RectSelection(this);
            this.m_AnimValueManager = new AnimValueManager();
            if (this.grid == null)
            {
                this.grid = new SceneViewGrid();
            }
            this.grid.Register(this);
            if (this.svRot == null)
            {
                this.svRot = new SceneViewRotation();
            }
            this.svRot.Register(this);
            base.autoRepaintOnSceneChange = true;
            this.m_AnimValueManager.Add(this.m_Rotation);
            this.m_AnimValueManager.Add(this.m_Position);
            this.m_AnimValueManager.Add(this.m_Size);
            this.m_AnimValueManager.Add(this.m_Ortho);
            this.m_AnimValueManager.callback = new AnimValueManager.Callback(this.Repaint);
            base.wantsMouseMove = true;
            base.dontClearBackground = true;
            s_SceneViews.Add(this);
            this.m_SceneViewOverlay = new SceneViewOverlay(this);
            EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction) Delegate.Combine(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(SceneView.RepaintAll));
            base.OnEnable();
        }

        private void OnFocus()
        {
            if (!Application.isPlaying && this.m_AudioPlay)
            {
                this.ToggleAudio();
            }
        }

        private static void OnForceEnableLights()
        {
            IEnumerator enumerator = s_SceneViews.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    SceneView current = (SceneView) enumerator.Current;
                    current.m_SceneLighting = true;
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable == null)
                {
                }
                disposable.Dispose();
            }
        }

        private void OnGUI()
        {
            if (Event.current.type == EventType.Repaint)
            {
                s_MouseRects.Clear();
            }
            Color color = GUI.color;
            if ((Event.current.type == EventType.MouseDown) || (Event.current.type == EventType.MouseDrag))
            {
                s_LastActiveSceneView = this;
            }
            else if (s_LastActiveSceneView == null)
            {
                s_LastActiveSceneView = this;
            }
            if (Event.current.type == EventType.MouseDown)
            {
                Tools.s_ButtonDown = Event.current.button;
                if ((Event.current.button == 1) && (Application.platform == RuntimePlatform.OSXEditor))
                {
                    base.Focus();
                }
            }
            if (Event.current.type == EventType.Layout)
            {
                this.m_ShowSceneViewWindows = lastActiveSceneView == this;
            }
            this.m_SceneViewOverlay.Begin();
            bool fog = RenderSettings.fog;
            float shadowDistance = QualitySettings.shadowDistance;
            if (Event.current.type == EventType.Repaint)
            {
                if (!this.m_SceneFx)
                {
                    Unsupported.SetRenderSettingsUseFogNoDirty(false);
                }
                if (this.m_Camera.isOrthoGraphic)
                {
                    Unsupported.SetQualitySettingsShadowDistanceTemporarily(QualitySettings.shadowDistance + (0.5f * this.cameraDistance));
                }
            }
            this.DoStatusBarGUI();
            GUI.skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);
            EditorGUIUtility.LookLikeControls(100f);
            this.SetupCamera();
            RenderingPath renderingPath = this.m_Camera.renderingPath;
            if (!this.m_SceneLighting)
            {
                this.m_Light[0].transform.rotation = this.m_Camera.transform.rotation;
                if (Event.current.type == EventType.Repaint)
                {
                    InternalEditorUtility.SetCustomLighting(this.m_Light, kSceneViewMidLight);
                }
            }
            GUI.BeginGroup(new Rect(0f, 17f, base.position.width, base.position.height - 17f));
            Rect position = new Rect(0f, 0f, base.position.width, base.position.height - 17f);
            if (Tools.viewToolActive && (Event.current.type == EventType.Repaint))
            {
                MouseCursor arrow = MouseCursor.Arrow;
                switch (Tools.viewTool)
                {
                    case ViewTool.Orbit:
                        arrow = MouseCursor.Orbit;
                        break;

                    case ViewTool.Pan:
                        arrow = MouseCursor.Pan;
                        break;

                    case ViewTool.Zoom:
                        arrow = MouseCursor.Zoom;
                        break;

                    case ViewTool.FPS:
                        arrow = MouseCursor.FPS;
                        break;
                }
                if (arrow != MouseCursor.Arrow)
                {
                    AddCursorRect(new Rect(0f, 17f, base.position.width, base.position.height - 17f), arrow);
                }
            }
            if (this.UseSceneFiltering())
            {
                EditorUtility.SetTemporarilyAllowIndieRenderTexture(true);
                if (this.m_SearchFilterTexture == null)
                {
                    this.m_SearchFilterTexture = new RenderTexture(0, 0, 0x18);
                    this.m_SearchFilterTexture.hideFlags = HideFlags.HideAndDontSave;
                }
                Rect cameraRect = Handles.GetCameraRect(position);
                if ((this.m_SearchFilterTexture.width != ((int) cameraRect.width)) || (this.m_SearchFilterTexture.height != ((int) cameraRect.height)))
                {
                    this.m_SearchFilterTexture.Release();
                    this.m_SearchFilterTexture.width = (int) cameraRect.width;
                    this.m_SearchFilterTexture.height = (int) cameraRect.height;
                }
                this.m_Camera.targetTexture = this.m_SearchFilterTexture;
                if (this.m_Camera.actualRenderingPath == RenderingPath.DeferredLighting)
                {
                    this.m_Camera.renderingPath = RenderingPath.Forward;
                }
            }
            else
            {
                this.m_Camera.targetTexture = null;
            }
            float verticalFOV = this.GetVerticalFOV(90f);
            float fieldOfView = this.m_Camera.fieldOfView;
            this.m_Camera.fieldOfView = verticalFOV;
            Handles.ClearCamera(position, this.m_Camera);
            this.m_Camera.fieldOfView = fieldOfView;
            this.m_Camera.cullingMask = Tools.visibleLayers;
            if (!this.UseSceneFiltering())
            {
                Handles.SetCamera(position, this.m_Camera);
                this.CallOnPreSceneGUI();
            }
            if (Event.current.type == EventType.Repaint)
            {
                Handles.SetSceneViewColors((Color) kSceneViewWire, (Color) kSceneViewWireOverlay, (Color) kSceneViewWireActive, (Color) kSceneViewWireSelected);
                if (this.m_OverlayMode == 2)
                {
                    if (s_ShowOverdrawShader == null)
                    {
                        s_ShowOverdrawShader = EditorGUIUtility.LoadRequired("SceneView/SceneViewShowOverdraw.shader") as Shader;
                    }
                    this.m_Camera.SetReplacementShader(s_ShowOverdrawShader, "RenderType");
                }
                else if (this.m_OverlayMode == 3)
                {
                    if (s_ShowMipsShader == null)
                    {
                        s_ShowMipsShader = EditorGUIUtility.LoadRequired("SceneView/SceneViewShowMips.shader") as Shader;
                    }
                    if (s_ShowMipsShader.isSupported)
                    {
                        CreateMipColorsTexture();
                        this.m_Camera.SetReplacementShader(s_ShowMipsShader, "RenderType");
                    }
                    else
                    {
                        this.m_Camera.SetReplacementShader(null, string.Empty);
                    }
                }
                else if (this.m_OverlayMode == 4)
                {
                    if (s_ShowLightmapsShader == null)
                    {
                        s_ShowLightmapsShader = EditorGUIUtility.LoadRequired("SceneView/SceneViewShowLightmap.shader") as Shader;
                    }
                    if (s_ShowLightmapsShader.isSupported)
                    {
                        this.m_Camera.SetReplacementShader(s_ShowLightmapsShader, "RenderType");
                    }
                    else
                    {
                        this.m_Camera.SetReplacementShader(null, string.Empty);
                    }
                }
                else
                {
                    this.m_Camera.SetReplacementShader(null, string.Empty);
                }
            }
            this.m_MainViewControlID = GUIUtility.GetControlID(FocusType.Keyboard);
            if (Event.current.GetTypeForControl(this.m_MainViewControlID) == EventType.MouseDown)
            {
                GUIUtility.keyboardControl = this.m_MainViewControlID;
            }
            if (this.m_Camera.gameObject.activeInHierarchy)
            {
                DrawGridParameters gridParam = this.grid.PrepareGridRender(this.camera, this.pivot, this.m_Rotation.target, (float) this.m_Size, this.m_Ortho.target, !this.m_SceneFx);
                if (this.UseSceneFiltering())
                {
                    if (Event.current.type == EventType.Repaint)
                    {
                        Handles.EnableCameraFx(this.m_Camera, true);
                        Handles.SetCameraFilterMode(this.m_Camera, Handles.FilterMode.ShowRest);
                        float fade = Mathf.Clamp01((float) (EditorApplication.timeSinceStartup - this.m_StartSearchFilterTime));
                        Handles.DrawCamera(position, this.m_Camera, this.m_RenderMode);
                        Handles.DrawCameraFade(this.m_Camera, fade);
                        RenderTexture.active = null;
                        Handles.EnableCameraFx(this.m_Camera, false);
                        Handles.SetCameraFilterMode(this.m_Camera, Handles.FilterMode.ShowFiltered);
                        if (s_AuraShader == null)
                        {
                            s_AuraShader = EditorGUIUtility.LoadRequired("SceneView/SceneViewAura.shader") as Shader;
                        }
                        this.m_Camera.SetReplacementShader(s_AuraShader, string.Empty);
                        Handles.DrawCamera(position, this.m_Camera, this.m_RenderMode);
                        this.m_Camera.ResetReplacementShader();
                        Handles.DrawCamera(position, this.m_Camera, this.m_RenderMode, gridParam);
                        if (fade < 1f)
                        {
                            base.Repaint();
                        }
                    }
                    Rect rect3 = position;
                    GUI.EndGroup();
                    GUI.BeginGroup(new Rect(0f, 17f, base.position.width, base.position.height - 17f));
                    GUI.DrawTexture(rect3, this.m_SearchFilterTexture, ScaleMode.StretchToFill, false, 0f);
                    Handles.SetCamera(position, this.m_Camera);
                    this.HandleSelectionAndOnSceneGUI();
                }
                else
                {
                    if (HandleUtility.CameraNeedsToRenderIntoRT(this.camera))
                    {
                        GUIClip.Push(new Rect(0f, 0f, base.position.width, base.position.height), Vector2.zero, Vector2.zero, true);
                    }
                    Handles.DrawCameraStep1(position, this.m_Camera, this.m_RenderMode, gridParam);
                    this.DrawAlphaOverlay();
                }
            }
            if (!this.m_SceneLighting && (Event.current.type == EventType.Repaint))
            {
                InternalEditorUtility.RemoveCustomLighting();
            }
            if (!this.UseSceneFiltering())
            {
                this.HandleSelectionAndOnSceneGUI();
            }
            else
            {
                EditorUtility.SetTemporarilyAllowIndieRenderTexture(false);
            }
            if ((Event.current.type == EventType.ExecuteCommand) || (Event.current.type == EventType.ValidateCommand))
            {
                this.CommandsGUI();
            }
            if (Event.current.type == EventType.Repaint)
            {
                Unsupported.SetRenderSettingsUseFogNoDirty(fog);
                Unsupported.SetQualitySettingsShadowDistanceTemporarily(shadowDistance);
            }
            this.m_Camera.renderingPath = renderingPath;
            if (!this.UseSceneFiltering())
            {
                Handles.DrawCameraStep2(this.m_Camera, this.m_RenderMode);
            }
            if (this.UseSceneFiltering())
            {
                Handles.SetCameraFilterMode(Camera.current, Handles.FilterMode.ShowFiltered);
            }
            else
            {
                Handles.SetCameraFilterMode(Camera.current, Handles.FilterMode.Off);
            }
            this.DefaultHandles();
            if (!this.UseSceneFiltering())
            {
                this.CallOnSceneGUIAfterGizmos();
            }
            if (HandleUtility.CameraNeedsToRenderIntoRT(this.camera) && !this.UseSceneFiltering())
            {
                GUIClip.Pop();
            }
            Handles.SetCameraFilterMode(Camera.current, Handles.FilterMode.Off);
            Handles.SetCameraFilterMode(this.m_Camera, Handles.FilterMode.Off);
            this.HandleDragging();
            this.svRot.HandleContextClick(this);
            this.svRot.OnGUI(this);
            SceneViewMotion.ArrowKeys(this);
            SceneViewMotion.DoViewTool(this.camera.transform, this);
            GUI.EndGroup();
            GUI.color = color;
            this.m_SceneViewOverlay.End();
            if (GUIUtility.hotControl == 0)
            {
                this.s_DraggingCursorIsCashed = false;
            }
            Rect rect = new Rect(0f, 0f, base.position.width, base.position.height);
            if (!this.s_DraggingCursorIsCashed)
            {
                MouseCursor cursor = MouseCursor.Arrow;
                if ((Event.current.type == EventType.MouseMove) || (Event.current.type == EventType.Repaint))
                {
                    foreach (CursorRect rect5 in s_MouseRects)
                    {
                        if (rect5.rect.Contains(Event.current.mousePosition))
                        {
                            cursor = rect5.cursor;
                            rect = rect5.rect;
                        }
                    }
                    if (GUIUtility.hotControl != 0)
                    {
                        this.s_DraggingCursorIsCashed = true;
                    }
                    if (cursor != s_LastCursor)
                    {
                        s_LastCursor = cursor;
                        InternalEditorUtility.ResetCursor();
                        base.Repaint();
                    }
                }
            }
            if ((Event.current.type == EventType.Repaint) && (s_LastCursor != MouseCursor.Arrow))
            {
                EditorGUIUtility.AddCursorRect(rect, s_LastCursor);
            }
        }

        public void OnSelectionChange()
        {
            base.Repaint();
        }

        internal static void PlaceGameObjectInFrontOfSceneView(GameObject go)
        {
            if (s_SceneViews.Count >= 1)
            {
                SceneView view = s_LastActiveSceneView;
                if (view == null)
                {
                    view = s_SceneViews[0] as SceneView;
                }
                if (view != null)
                {
                    view.MoveToView(go.transform);
                }
            }
        }

        public static void RepaintAll()
        {
            IEnumerator enumerator = s_SceneViews.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    ((SceneView) enumerator.Current).Repaint();
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable == null)
                {
                }
                disposable.Dispose();
            }
        }

        private void ResetIfNaN()
        {
            if (float.IsInfinity(this.m_Position.value.x) || float.IsNaN(this.m_Position.value.x))
            {
                this.m_Position.value = Vector3.zero;
            }
            if (float.IsInfinity(this.m_Rotation.value.x) || float.IsNaN(this.m_Rotation.value.x))
            {
                this.m_Rotation.value = Quaternion.identity;
            }
        }

        public void SetSceneViewFiltering(bool enable)
        {
            this.m_RequestedSceneViewFiltering = enable;
        }

        internal override void SetSearchFilter(string searchFilter, SearchableEditorWindow.SearchMode searchMode, bool setAll)
        {
            if ((base.m_SearchFilter == string.Empty) || (searchFilter == string.Empty))
            {
                this.m_StartSearchFilterTime = EditorApplication.timeSinceStartup;
            }
            base.SetSearchFilter(searchFilter, searchMode, setAll);
        }

        private void Setup()
        {
            System.Type[] components = new System.Type[] { typeof(Camera) };
            GameObject obj2 = EditorUtility.CreateGameObjectWithHideFlags("SceneCamera", HideFlags.HideAndDontSave, components);
            obj2.AddComponent("FlareLayer");
            obj2.AddComponent("HaloLayer");
            this.m_Camera = obj2.camera;
            this.m_Camera.enabled = false;
            for (int i = 0; i < 3; i++)
            {
                System.Type[] typeArray2 = new System.Type[] { typeof(Light) };
                GameObject obj3 = EditorUtility.CreateGameObjectWithHideFlags("SceneLight", HideFlags.HideAndDontSave, typeArray2);
                this.m_Light[i] = obj3.light;
                this.m_Light[i].type = LightType.Directional;
                this.m_Light[i].intensity = 0.5f;
                this.m_Light[i].enabled = false;
            }
            this.m_Light[0].color = kSceneViewFrontLight;
            this.m_Light[1].color = kSceneViewUpLight - kSceneViewMidLight;
            this.m_Light[1].transform.LookAt(Vector3.down);
            this.m_Light[1].renderMode = LightRenderMode.ForceVertex;
            this.m_Light[2].color = kSceneViewDownLight - kSceneViewMidLight;
            this.m_Light[2].transform.LookAt(Vector3.up);
            this.m_Light[2].renderMode = LightRenderMode.ForceVertex;
            HandleUtility.handleMaterial.SetColor("_SkyColor", (Color) (kSceneViewUpLight * 1.5f));
            HandleUtility.handleMaterial.SetColor("_GroundColor", (Color) (kSceneViewDownLight * 1.5f));
            HandleUtility.handleMaterial.SetColor("_Color", (Color) (kSceneViewFrontLight * 1.5f));
        }

        private void SetupCamera()
        {
            if (this.m_Camera == null)
            {
                this.Setup();
            }
            if (this.m_OverlayMode == 2)
            {
                this.m_Camera.backgroundColor = Color.black;
            }
            else
            {
                this.m_Camera.backgroundColor = (Color) kSceneViewBackground;
            }
            this.ResetIfNaN();
            this.m_Camera.transform.rotation = (Quaternion) this.m_Rotation;
            float aspectNeutralFOV = this.m_Ortho.Fade(90f, 0f);
            if (aspectNeutralFOV > 3f)
            {
                this.m_Camera.orthographic = false;
                this.m_Camera.fieldOfView = this.GetVerticalFOV(aspectNeutralFOV);
            }
            else
            {
                this.m_Camera.orthographic = true;
                this.m_Camera.orthographicSize = this.GetVerticalOrthoSize();
            }
            this.m_Camera.transform.position = (Vector3) (this.m_Position + (this.m_Camera.transform.rotation * new Vector3(0f, 0f, -this.cameraDistance)));
            if (this.size < 1f)
            {
                this.m_Camera.near = 0.005f;
                this.m_Camera.far = 1000f;
            }
            else if (this.size < 100f)
            {
                this.m_Camera.near = 0.03f;
                this.m_Camera.far = 3000f;
            }
            else if (this.size < 1000f)
            {
                this.m_Camera.near = 0.5f;
                this.m_Camera.far = 20000f;
            }
            else
            {
                this.m_Camera.near = 1f;
                this.m_Camera.far = 1000000f;
            }
            this.m_Camera.renderingPath = GetSceneViewRenderingPath();
            Handles.EnableCameraFx(this.m_Camera, this.m_SceneFx);
            this.m_Light[0].transform.position = this.m_Camera.transform.position;
            this.m_Light[0].transform.rotation = this.m_Camera.transform.rotation;
            if (this.m_AudioPlay)
            {
                AudioUtil.SetListenerTransform(this.m_Camera.transform);
                AudioUtil.UpdateAudio();
            }
        }

        public static void ShowCompileErrorNotification()
        {
            ShowNotification("All compiler errors have to be fixed before you can enter playmode!");
        }

        internal static void ShowNotification(string notificationText)
        {
            UnityEngine.Object[] objArray = Resources.FindObjectsOfTypeAll(typeof(SceneView));
            List<EditorWindow> list = new List<EditorWindow>();
            foreach (SceneView view in objArray)
            {
                if (view.m_Parent is DockArea)
                {
                    DockArea parent = (DockArea) view.m_Parent;
                    if ((parent != null) && (parent.actualView == view))
                    {
                        list.Add(view);
                    }
                }
            }
            if (list.Count > 0)
            {
                foreach (EditorWindow window in list)
                {
                    window.ShowNotification(GUIContent.Temp(notificationText));
                }
            }
            else
            {
                Debug.LogError(notificationText);
            }
        }

        internal static void ShowSceneViewPlayModeSaveWarning()
        {
            ShowNotification("You must exit play mode to save the scene!");
        }

        private void ToggleAudio()
        {
            if (((s_AudioSceneView != null) && (s_AudioSceneView != this)) && s_AudioSceneView.m_AudioPlay)
            {
                s_AudioSceneView.m_AudioPlay = false;
                s_AudioSceneView.Repaint();
            }
            AudioSource[] sourceArray = (AudioSource[]) UnityEngine.Object.FindObjectsOfType(typeof(AudioSource));
            foreach (AudioSource source in sourceArray)
            {
                if (source.playOnAwake)
                {
                    if (!this.m_AudioPlay)
                    {
                        source.Stop();
                    }
                    else if (!source.isPlaying)
                    {
                        source.Play();
                    }
                }
            }
            AudioUtil.SetListenerTransform(!this.m_AudioPlay ? null : this.m_Camera.transform);
            s_AudioSceneView = this;
        }

        private bool UseSceneFiltering()
        {
            return (!string.IsNullOrEmpty(base.m_SearchFilter) || this.m_RequestedSceneViewFiltering);
        }

        [UnityEditor.MenuItem("GameObject/Align View to Selected", true)]
        private static bool ValidateAlignViewToSelected()
        {
            return ((s_LastActiveSceneView != null) && (Selection.activeTransform != null));
        }

        [UnityEditor.MenuItem("GameObject/Align With View %#f", true)]
        private static bool ValidateAlignWithView()
        {
            return ((s_LastActiveSceneView != null) && (Selection.activeTransform != null));
        }

        [UnityEditor.MenuItem("GameObject/Move To View %f", true)]
        private static bool ValidateMoveToView()
        {
            return ((s_LastActiveSceneView != null) && (Selection.transforms.Length != 0));
        }

        public Camera camera
        {
            get
            {
                return this.m_Camera;
            }
        }

        internal float cameraDistance
        {
            get
            {
                float num = this.m_Ortho.Fade(90f, 0f);
                if (!this.camera.orthographic)
                {
                    return (this.size / Mathf.Tan((num * 0.5f) * 0.01745329f));
                }
                return (this.size * 2f);
            }
        }

        internal Vector3 cameraTargetPosition
        {
            get
            {
                return (this.m_Position.target + (this.m_Rotation.target * new Vector3(0f, 0f, -this.cameraDistance)));
            }
        }

        internal Quaternion cameraTargetRotation
        {
            get
            {
                return this.m_Rotation.target;
            }
        }

        public static SceneView currentDrawingSceneView
        {
            get
            {
                return s_CurrentDrawingSceneView;
            }
        }

        public static SceneView lastActiveSceneView
        {
            get
            {
                return s_LastActiveSceneView;
            }
        }

        public bool orthographic
        {
            get
            {
                return this.m_Ortho.value;
            }
            set
            {
                this.m_Ortho.value = value;
            }
        }

        public Vector3 pivot
        {
            get
            {
                return (Vector3) this.m_Position;
            }
            set
            {
                this.m_Position.value = value;
            }
        }

        public DrawCameraMode renderMode
        {
            get
            {
                return this.m_RenderMode;
            }
            set
            {
                this.m_RenderMode = value;
            }
        }

        public Quaternion rotation
        {
            get
            {
                return (Quaternion) this.m_Rotation;
            }
            set
            {
                this.m_Rotation.value = value;
            }
        }

        public static ArrayList sceneViews
        {
            get
            {
                return s_SceneViews;
            }
        }

        public float size
        {
            get
            {
                return (float) this.m_Size;
            }
            set
            {
                if (value > 40000f)
                {
                    value = 40000f;
                }
                this.m_Size.value = value;
            }
        }

        [StructLayout(LayoutKind.Sequential)]
        private struct CursorRect
        {
            public Rect rect;
            public MouseCursor cursor;
            public CursorRect(Rect rect, MouseCursor cursor)
            {
                this.rect = rect;
                this.cursor = cursor;
            }
        }

        public delegate void OnSceneFunc(SceneView sceneView);
    }
}

